﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;

using com.vs.DataAccess;
using com.vs.DataAccess.DO;
using com.vs.General;
using com.vs.Inventory.BL;
using com.vs.Task.BL;

namespace com.vs.Shipping.BL
{
    public class ShippingHelper
    {

        public string AssignToLoad(Session sess, int iIntShpNum)
        {
            return null;
        }

        public string CloseShipment(Session sess, int iIntShpNum)
        {
            return null;
        }

        public string DispatchLoad(Session sess, int iShpLoad)
        {
            return null;
        }

        public string CancelShipmentFromWave(Session sess, int iShpNum)
        {
            DataHelper helper = null;

            try
            {
                helper = new DataHelper(sess);
                return helper.GetString(CommandType.StoredProcedure, "SHP_CancelFromWave", new IDataParameter[]{
                    DataHelper.BuildParameter(sess, "@INTERNAL_SHIPMENT_NUM", iShpNum)});
            }
            catch (Exception e)
            {
                ExceptionManager.LogException(sess, e);
                return MessageManager.MSG_GEN_000 + e.Message;
            }
            finally
            {
                if (helper != null)
                    helper.Dispose();
            }
        }

        private string CreatePickingTask()
        {
            return null;
        }

        private string ValidateShipmentBefAllocation(Session sess, int iShpNum)
        {
            return null;
        }

        public DataTable GetAvailableInventory(Session sess, int iIntShpNum)
        {
            DataHelper helper = null;
            DataTable dtModel = null;
            string stSQL = "SHP_RAvailableInventory";

            try
            {
	            helper = new DataHelper(sess);
	            dtModel = helper.GetTable(CommandType.StoredProcedure, stSQL, new IDataParameter[] { 
				            DataHelper.BuildParameter(sess, "@INTERNAL_SHIPMENT_NUM", iIntShpNum),
			            });
                return dtModel;
            }
            catch (Exception e)
            {
	            ExceptionManager.LogException(sess, e);
	            return null;
            }
            finally
            {
	            if (helper != null)
		            helper.Dispose();
            }

        }
    }
}
